﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ApplicationForm.aspx.cs" Inherits="CRMWeb.Pages.Contact.ApplicationForm" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <table id="dgApplicationContactForm"  style="width: auto;" autorowheight="true" 
        rownumbers="true" fitcolumns="true" singleselect="true">
        <thead>
            <tr>
                <th field="app_id" hidden="true">Application-ID</th>
                <th field="cdate" width="30">Date Created</th>
                <th field="app_Date1"  width="15" data-options="formatter:calculateAge">Age</th>
                <th field="app_LoanAmount"  width="20" data-options="formatter:ReplaceNumberWithCommas">Desired Amount</th>
                <th field="assets"  width="30" >Assets</th>
                <th field="ClientName" width="100"> Name </th>
            </tr>
        </thead>
    </table>
    <script type="text/javascript">
        function ReplaceNumberWithCommas(yourNumber) {
            if (yourNumber != null) {
                //Seperates the components of the number
                var components = yourNumber.toString().split(".");
                //Comma-fies the first part
                components[0] = components[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
                //Combines the two sections
                return "$" + components.join(".");
            }
        }
        function calculateAge(value, row) {
            var date = null;
            if (value == null)
                date = new Date();
            else
                date = new Date(value);
            var y = date.getFullYear();
            var m = date.getMonth() + 1;
            var d = date.getDate();
            return getAge((m < 10 ? ('0' + m) : m) + '/' + (d < 10 ? ('0' + d) : d) + '/' + y);
        }
        $(document).ready(function () {
            $('#dgApplicationContactForm').datagrid({
                url: '/WebServices/ApplicationContact.ashx?method=BindApplicationContactForm&ContactID=' + getQuerystring('contact_id', ''),
                onDblClickRow: function (index, rowdata) {
                    var newTab = window.open('/Pages/Application_Form.aspx?verified=0&id=' + rowdata.app_id, '_blank');
                    newTab.focus();
                }
            });
        });
    </script>
</body>
</html>
